#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
交易 - 退款查询功能使用示例
"""

import os
import sys

# 添加项目根目录到Python路径
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))))

from examples.base_example import BaseExample
from jlpay.services.trans.refunds.refunds_query_service import RefundsQueryService
from jlpay.model.trans.refunds.refunds_query import RefundsQueryRequest


class RefundsQueryExample(BaseExample):
    """退款查询示例类"""
    
    def __init__(self):
        """初始化示例类"""
        super().__init__("examples.trans.refunds.refunds_query")
        self.service = RefundsQueryService(self.config)
    
    def build_refunds_query_request(self):
        """
        构建退款查询请求
        
        Returns:
            RefundsQueryRequest实例
        """
        request = RefundsQueryRequest()
        request.set_mch_id("849581183510017")
        #request.set_transaction_id("451147688260420350771289")
        request.set_out_trade_no("0c12656513f74a8f")
        return request
    
    def refunds_query_demo(self):
        """退款查询示例"""
        self.logger.info("开始执行退款查询示例")
        
        # 构建请求
        request = self.build_refunds_query_request()
        
        # 发送请求并处理响应
        self.send_request_and_handle_response(
            self.service.refunds_query, 
            "退款查询",
            request
        )
        
        self.logger.info("退款查询示例执行完毕")


def main():
    """主函数"""
    example = RefundsQueryExample()
    example.refunds_query_demo()


if __name__ == "__main__":
    main() 